<html>

	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<meta name="generator" content="Adobe GoLive 5">
		<title>Tutorial 3. Multiple Platforms</title>
		<link rel="stylesheet" href="../cps.css">
	</head>

	<body bgcolor="#d3d3d3" text="black">
		<h1>Tutorial 3. JADE Inter Platform Communication Using IIOP</h1>
		<p>In Tutorial 2 we saw a simple JADE platform consisting of containers which could be scattered among many different hosts with one Main container on a host running the RMI service. All the agents on one platform communicate using the RMI protocol. RMI is the intra-container communication mechanism internal to a platform.</p>
		<p>JADE agents can also communicate among separate platforms, in other words, JADE provides mechanisms called Message Transport Protocols (MTP) for inter-platform communication. These MTPs use the IIOP protocol associated with CORBA  or the HTTP protocol. Such arrangements allows JADE agents to talk to <a href="http://www.fipa.org/e!)">FIPA</a> (Foundation for Intelligent Physical Agents) compliant agents on any platform supporting FIPA standards, even if non-Java based. This is the whole idea of FIPA: to make diverse agent systems interoperable.</p>
		<p>This tutorial shows how to use the basic Sun IIOP for inter-platform communication.</p>
		<p>In this tutorial you just get the DummyAgent talking to the PingAgent, one on one platform, the other on another platform. You could run two platforms on one machine, provided you use different ports for the RMI servers. But things are clearer and more typical if the platforms run on different hosts.</p>
		<h3>Running JADE with IIOP</h3>
		<p>Until JADE 3.1 the IIOP&nbsp;protocol was JAD'E's  default MTP for inter-platform commuication. Users who needed a HTTP&nbsp;MTP needed an add-on. Starting with version 3.2 JADE has a built-in HTTP MTP&nbsp;which is also the default. (See Tutorial 4 for information on using the HTTP&nbsp;MTP.) The IIOP MTP&nbsp;is also built-in, but is not the default. To use the IIOP&nbsp;MTP&nbsp;you mest access it using a command line argument when you boot JADE. </p>
		<p>To bring up the IIOP&nbsp;MTP do the following in a Console window:</p>
		<dl>
			<dd>runjade -gui -mtp jade.mtp.iiop.MessageTransportProtocol
		</dl>
		<p>(where runjade.bat is the batch file used in prevous tutorials.)</p>
		<h3>What is that big number that appears when booting a platform?</h3>
		<p>When you invoke java jade.Boot -gui -mtp jade.mtp.iiop.MessageTransportProtocol, you get something like this on the Java console (DOS window):</p>
		<p>IOR:000000000000001149444C3A464950412F4D54533A312E3000000000000000010000000000000054000101000000000C3139322E3136382E302E350007CE000000000018AFABCAFF00000002234298670000000800000000000000000000000100000001000000140000000000010020000000000001010000000000<br>
		</p>
		<p>You will also find it stored in a file called MTP-Main-Container.txt in the<i> jade</i> directory. </p>
		<p>What is it? Well, it acts as a CORBA address, or end point. This strange value occurs because by default JADE uses Sun's JDK 1.3 CORBA/iiop implementation which is rather primitive. (The JADE team has provided a more sophisticated ORB which allows explicit addressing.)</p>
		<p>To send messages between default versions of JADE platforms you need to use this end point as an agent address, which is rather awkward.</p>
		<h2>Setting Up</h2>
		<p>Boot JADE on both machines using the IIOP&nbsp;value for the -mtp switch, as shown above.</p>
		<dl>
				</dl>
		<p>Now, as usual, we want to send a message from a DummyAgent to a PingAgent, this time with the agents residing on separate platforms, not just in separate containers on the same platform. To do this we use the IOR's as the addresses for the agents.</p>
		<h2> End Points</h2>
		<p>The IIOP IOR (endpoint - &quot;Identifying Object Reference&quot;) of a platform is automatically stored in a file called MTP-Main-Contairner.txt. A sender of a message must know the receivers IOR so somehow, the sender must get a hold of the MTP-Main-Container.txt file of the receiver. One could use ftp. On a LAN with MS Windows you can just copy the file or even just cut and paste its contents.</p>
		<p>The platform with the DummyAgent needs to know the IOR of the platform with the PingAgent in order to send it a message. (Of course it knows its own IOR.) </p>
		<p>In this tutorial we just use &quot;My Network Places&quot; with the editor NotePad to open the receiver's file and copy the IOR to the Receiver field of the DummyAgent.</p>
		<div align="left">
			<table cool width="340" height="278" usegridx usegridy showgridx showgridy gridx="16" gridy="16" border="0" cellpadding="0" cellspacing="0" align="right">
				<tr height="16">
					<td width="304" height="16"></td>
					<td width="35" height="277" rowspan="2"></td>
					<td width="1" height="16"><spacer type="block" width="1" height="16"></td>
				</tr>
				<tr height="261">
					<td content csheight="261" width="304" height="261" valign="top" align="left" xpos="0"><font color="blue">Recall that to add a receiver to the DummyAgent right click on the receivers field and choose add. This brings up the AID window. Enter the full name of the PingAgent, e.g., ping0@Frodo:1099/JADE. Then right click the address field in the AID&nbsp;window and use ctrl-v to paste the IOR into this field.</font></td>
					<td width="1" height="261"><spacer type="block" width="1" height="261"></td>
				</tr>
				<tr height="1" cntrlrow>
					<td width="304" height="1"><spacer type="block" width="304" height="1"></td>
					<td width="35" height="1"><spacer type="block" width="35" height="1"></td>
					<td width="1" height="1"></td>
				</tr>
			</table>
		</div>
		<p> On MS Windows you type ctrl-v to do the pasting. </p>
		<p><i>Remember to avoid the cr/lf from the end of the IOR, if necessary)</i>. You can see from the pictures below that you get a visual clue if you have entered the IOR correctly.</p>
		<table cool width="611" height="345" usegridx usegridy showgridx showgridy gridx="16" gridy="16" border="0" cellpadding="0" cellspacing="0">
			<tr height="32">
				<td width="610" height="32" colspan="5"></td>
				<td width="1" height="32"><spacer type="block" width="1" height="32"></td>
			</tr>
			<tr height="191">
				<td width="16" height="312" rowspan="2"></td>
				<td content csheight="171" width="208" height="191" valign="top" align="left" xpos="16">The IOR with a cr/lf (bad)
					<p>(So be careful to avoid the cr/lf when you copy the IOR from your editor)</p>
				</td>
				<td width="32" height="191" colspan="2"></td>
				<td width="354" height="191" valign="top" align="left" xpos="256"><img src="images/IORWithCR.gif" width="306" height="121" border="0"></td>
				<td width="1" height="191"><spacer type="block" width="1" height="191"></td>
			</tr>
			<tr height="121">
				<td content csheight="79" width="224" height="121" colspan="2" valign="top" align="left" xpos="16">The IOR correctly entered without a CR/LF</td>
				<td width="16" height="121"></td>
				<td width="354" height="121" valign="top" align="left" xpos="256"><img src="images/IORCorrect.gif" width="306" height="121" border="0"></td>
				<td width="1" height="121"><spacer type="block" width="1" height="121"></td>
			</tr>
			<tr height="1" cntrlrow>
				<td width="16" height="1"><spacer type="block" width="16" height="1"></td>
				<td width="208" height="1"><spacer type="block" width="208" height="1"></td>
				<td width="16" height="1"><spacer type="block" width="16" height="1"></td>
				<td width="16" height="1"><spacer type="block" width="16" height="1"></td>
				<td width="354" height="1"><spacer type="block" width="354" height="1"></td>
				<td width="1" height="1"></td>
			</tr>
		</table>
		<p></p>
		<p></p>
		<p>The AID window should look something like this:</p>
		<p><img src="images/AIDCorba.gif" width="226" height="306" border="0"></p>
		<p>Do not check the box indicating a local name. Fill in the full,global name (with the @ sign and the RMI platform address.)</p>
		<p>Click OK and then send the message to the ping0 agent.</p>
		<h2>Send the Message</h2>
		<p>Finally, you are ready to send the same message as before, from the DummyAgent to the PingAgent. Everything should run just like in all the previous tutorial examples. The QUERY-REF informative is sent by the DummyAgent, and the PingAgent sends an INFORM message in reply. Click the &quot;eyeglasses&quot; button to see the content of the reply (&quot;alive&quot;).</p>
		<p>Note that the message sent by the DummyAgent includes the return address (IOR of the platform on which the DummyAgent is running so you only need to copy one IOR, that of the receiver.</p>
		<h2>Comment</h2>
		<p>Using the JDK 1.3 CORBA/IIOP ORB is clearly very awkward. It would be well to install the Orbacus ORB add on (see the distribution documentation on doing this) which allows the standard host:port addressing for the endpoints.</p>
		<p>Most people prefer the HTTP MTP which is the default in the JADE 3.2  (and later) distribution for inter platform communication. Tutorial 4 of these notes shows how to do this.</p>
		<h2>Contacting the Remote Platform</h2>
		<p>You will notice a menu entry of the RMA agent (the GUI&nbsp;for the platform) called &quot;Remote Platforms&quot;. If you click it you see two ways of contacting a remote platform. The easiest is &quot;add platform via AMS AID&quot;.</p>
		<p>If you click this you get a window which allows you to enter the AMS agent's name and location. For the name you need the global name of the target AMS, for example, ams@frodo:1099/JADE. For the address you need to copy in the IOR of that remote platform.</p>
		<p>You should see a new entry in the RMA agent for the remote platform. To view its contents select and right click. The choose &quot;Refresh agent list&quot; and you should see all the agents on the remote platform. It might look like this:</p>
		<p><img src="images/remotePlatform.gif" alt="" height="400" width="600" border="0"></p>
		<p></p>
	</body>

</html>